package com.yjr.server.authentication.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yjr.server.busines.aclUser.entiy.User;
import com.yjr.server.busines.aclUser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author yjr
 * @version 1.0.0
 * @ClassName Authentication.java
 * @Description TODO
 * @createTime 2021年12月02日 18:05:00
 */
@RestController
@RequestMapping("/Authentication")
public class Authentication {
    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public String login(String username, String password, HttpServletRequest req) {

        User one = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getUsername, username).eq(User::getPassword, password));
        if(one!=null){
            return "success";
        }else {
            return "error";
        }
        /*this.checkLoginInfo(username, password);
        req.getSession().setAttribute("isLogin", true);
        return "success";*/
    }
}
